package com.bw.liuyushan.liuyushan20210929.Adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bw.liuyushan.liuyushan20210929.GreenDao.GoodBean;
import com.bw.liuyushan.liuyushan20210929.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * Liuyushan20210929
 * file name is : GoodCarAdapter
 * created by Ender on 2021/9/29 18:11.
 * author : 刘雨杉
 * Describe:
 */
public class GoodCarAdapter extends BaseQuickAdapter<GoodBean, BaseViewHolder> {
    public GoodCarAdapter(@Nullable List<GoodBean> data) {
        super(R.layout.rv_car, data);
        addChildClickViewIds(R.id.cb,R.id.pay);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, GoodBean goodBean) {
        baseViewHolder.setText(R.id.rv_name,goodBean.getTitle());
        baseViewHolder.setText(R.id.tv_price,goodBean.getPrice());
        Glide.with(getContext()).load(goodBean.getPic()).into((ImageView) baseViewHolder.findView(R.id.image_car));
        CheckBox checkBox = baseViewHolder.itemView.findViewById(R.id.cb);
        if (goodBean.getGetCheacks()){
            checkBox.setChecked(goodBean.getGetCheacks());
        }else{
            checkBox.setChecked(goodBean.getGetCheacks());
        }

    }
}
